//
//  HuaTiViewController.m
//  網易
//
//  Created by 赵天宇 on 16/8/22.
//  Copyright © 2016年 赵天宇. All rights reserved.
//

#import "HuaTiViewController.h"
#import "AddViewController.h"
#import "AppDelegate.h"
@interface HuaTiViewController ()<UITableViewDataSource,UITableViewDelegate>{
    UITableView *tableV;
    AppDelegate *app;
}

@end

@implementation HuaTiViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    app=[UIApplication sharedApplication].delegate;
    app.arrImage = [NSMutableArray array];
    app.arrTitle = [NSMutableArray array];
    [app.arrImage addObject:[UIImage imageNamed:@"1111.jpg"]];
    [app.arrImage addObject:[UIImage imageNamed:@"sd sd .jpg"]];
    [app.arrImage addObject:[UIImage imageNamed:@"222.jpg"]];
    [app.arrTitle addObject:@"哈雷彗星"];
    [app.arrTitle addObject:@"魅力自然"];
    [app.arrTitle addObject:@"铁血丹心"];
    tableV=[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
    tableV.delegate=self;
    tableV.dataSource=self;
    [self.view addSubview:tableV];
    tableV.rowHeight=200;
    self.navigationController.navigationBar.barStyle=UIBarStyleBlack;
    self.navigationController.navigationBar.barTintColor=[UIColor redColor];
    self.navigationItem.title=@"老百姓自己的新闻";
    UIBarButtonItem *rightItem  = [[UIBarButtonItem alloc]initWithTitle:@"Edit" style:UIBarButtonItemStylePlain target:self action:@selector(send)];
    self.navigationItem.rightBarButtonItem=rightItem;           
    self.navigationItem.rightBarButtonItem.tintColor=[UIColor whiteColor];
}
//发送
-(void)send{
    AddViewController *aa = [[AddViewController alloc]init];
    [self.navigationController pushViewController:aa animated:YES];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return app.arrImage.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *ss=@"love";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ss];
    if(!cell){
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ss];
    }
    UIImageView *imageV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 200)];
    imageV.image =app.arrImage[indexPath.row];
    [cell.contentView addSubview:imageV];
    UILabel *ll = [[UILabel alloc]initWithFrame:CGRectMake(10, 105, self.view.frame.size.width, 30)];
    [ll setFont:[UIFont fontWithName:@"Helvetica-Bold" size:20]];
    ll.alpha=0.5;
    ll.textColor=[UIColor whiteColor];
    ll.text=app.arrTitle[indexPath.row];
    [cell.contentView addSubview:ll];
    return cell;
}
-(void)viewWillAppear:(BOOL)animated{
    [tableV reloadData];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
